// ==============================================================
// BeaconArray.h
// Part of the ORBITER VISUALISATION PROJECT (OVP)
// Released under GNU General Public License
// Copyright (C) 2012 Jarmo Nikkanen
// ==============================================================


#ifndef __BEACONARRAY_H
#define __BEACONARRAY_H

#include "D3D9Client.h"
#include "D3D9Effect.h"
#include <d3d9.h> 
#include <d3dx9.h>


typedef struct {
	VECTOR3 pos;	// Beacon position relative to visual origin (base origin)
	VECTOR3 dir;	// Light direction. (1,0,0)=South (0,1,0)=Up (0,0,1)=East
	DWORD	color;  // Light color
	float	size;	// Size of the beacon in meters
	float   angle;	// Light cone angle in degrees
	float	lon;	// Light on time
	float   loff;	// Light off time if (lon=0, loff=1) light always on
	float   bright; // Light brightness factor. 1.0 = default
	float   fall;   // Spotlight falloff speed 2.0 to 0.1; 
} BeaconArrayEntry;



/**
 * \brief BeaconArray object with D3D9-specific vertex buffer
 *
 */

class BeaconArray : public D3D9Effect 
{

public:

	/**
	 * \brief Create a BeaconArray object for rendering multible beacons at the same time
	 * \param pArray Pointer into a BeaconArrayEntry list
	 * \param nArray Number of entries in the array
	 */
	BeaconArray(const BeaconArrayEntry *pArray, DWORD nArray);
	~BeaconArray();
	
	void UnLockVertexBuffer();
	BAVERTEX * LockVertexBuffer();

	void Render(LPDIRECT3DDEVICE9 dev, const LPD3DXMATRIX pW, float time=0.5f);

private:

	DWORD nVert;
	LPDIRECT3DVERTEXBUFFER9 pVB;
	SURFHANDLE pBright;
};

#endif // !__BEACONARRAY_H